﻿#include "personitem.h"
#include "ui_personitem.h"

PersonItem::PersonItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PersonItem)
{
    ui->setupUi(this);
}

PersonItem::~PersonItem()
{
    delete ui;
}

// 设置用户头像
void PersonItem::SetPost(const QByteArray &photo)
{
    QPixmap pixmap;
    pixmap.loadFromData(photo); // 从二进制数据中加载一张图片
    ui->label_post->setPixmap(pixmap.scaled(ui->label_post->size()));
}

// 设置用户名字
void PersonItem::SetName(const QString &name)
{
    ui->label_name->setText(name);
}

QString PersonItem::GetName()
{
    return ui->label_name->text();
}
